package Test;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA
 * User: HUAWEI
 * Date: 2023-06-03
 * Time: 15:41
 */

//https://www.nowcoder.com/exam/oj?page=1&tab=%E8%AF%AD%E6%B3%95%E7%AF%87&topicId=220


    //01 基础语法
//基本数据类型
//JAVA1
//设计一个方法，将一个小于2147483647的double类型变量以截断取整方式转化为int类型

    /*
    import java.util.Scanner;

    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            double d = scanner.nextDouble();
            System.out.println(Main.typeConversion(d));
        }
        public static int typeConversion(double d) {
            return (int) d;
        }
    }*/

//运算符
//java2
//输入两个正整数a和b，输出这两个正整数的和，差，积，商，模
// （若a>b则输出a-b，a/b，a%b的值反之输出b-a，b/a，b%a的值，不考虑小数，请使用int类型）
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        scanner.close();

        //write your code here......
        int max = 0;
        int min = 0;
        max = a>b?a:b;
        min = a<b?a:b;
        int sum = max + min;
        int sub = max - min;
        int pro = max*min;
        int quo = max/min;
        int mod = max%min;
        System.out.println(sum+" "+sub+" "+pro+" "+quo+" "+mod);
    }
}*/

//JAVA3
//定义一个int类型变量i,i为由浮点数变量d四舍五入后的整数类型，请将转换后的i进行输出
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double d= scanner.nextDouble();
        //write your code here......
        int i = (int)(d + 0.5);
        System.out.println(i);
    }
}*/


//JAVA4
//在不使用第三个变量的情况下交换两个int类型变量的值
/*import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        a = a^b;
        b = a^b;
        a = a^b;
        System.out.println(a+" "+b);
    }
}*/

//分支
//JAVA5
//牛大姨账单钱数（int类型）
/*import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int price = console.nextInt();
        int cost = 0;
        if (price < 1) {
            cost = 0;
        }else if (price >=1 && price < 100) {
            cost = price;
        }else if (price >= 100 && price <500) {
            price *= 0.9;
            cost = price;
        }else if (price >= 500 && price <2000) {
            price *= 0.8;
            cost = price;
        }else if (price >= 2000 && price <5000) {
            price *= 0.7;
            cost = price;
        }else {
            price *= 0.6;
            cost = price;
        }
        System.out.println(cost);
    }
}*/


    //JAVA6
    //编写一段逻辑，算出输入了身高和体重的用户的体重指数，并返回他们的身材状态。(体重指数请使用double类型)
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double height = scanner.nextDouble();
        double weight = scanner.nextDouble();

        //write your code here......
        double weightPoint = weight/(height*height);
        if (weightPoint < 18.5) {
            System.out.println("偏瘦");
        }else if (weightPoint >= 18.5 && weightPoint < 20.9) {
            System.out.println("苗条");
        }else if (weightPoint >= 20.9 && weightPoint <= 24.9) {
            System.out.println("适中");
        }else {
            System.out.println("偏胖");

        }
    }
}*/

    //JAVA7
    //成绩等级对应的中文表述
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String grade =scanner.next();

        //write your code here......
        if (grade.equals("A")) {
            System.out.println("优秀");
        }else if (grade.equals("B")){
            System.out.println("良好");
        }else if (grade.equals("C")){
            System.out.println("及格");
        }else if (grade.equals("D")){
            System.out.println("不及格");
        }else {
            System.out.println("未知等级");
        }
    }
}*/

    //JAVA8
    //请根据给出的正则表达式来验证邮箱格式是否合法，如果用户输入的格式合法则输出「邮箱格式合法」，否则输出「邮箱格式不合法」。
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        String emailMatcher="[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+";

        //write your code here......
        if (str.matches(emailMatcher)) {
            System.out.println("邮箱格式合法");
        }else {
            System.out.println("邮箱格式不合法");
        }
    }
}*/
// matches
/*    matches() 方法用于检测字符串是否匹配给定的正则表达式。
            调用此方法的 str.matches(regex) 形式与以下表达式产生的结果完全相同
            regex 这里写格式
*/


//循环
//JAVA9
//有数列为：9，99，999，...，9999999999。要求使用程序计算此数列的和，
// 并在控制台输出结果。（请尝试使用循环的方式生成这个数列并同时在循环中求和）
/*public class Main {
    public static void main(String[] args) {
        long sum = 0;
        long num = 9;
        for (int i = 1; i <= 10; i++) {
            sum += num;
            //System.out.println(num);
            num = num + 9*(long)Math.pow(10,i);
        }
        System.out.println(sum);
    }
}*/

//JAVA10
//控制台输入整数，请设计一个死循环，当用户输入非正数时停止输入。请给出用户输入的正整数个数（默认输入个数不超过2147483647）
/*import java.util.*;

public class Main {
    public static void main(String[] args) {
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int num = scanner.nextInt();
            if (num <= 0) {
                break;
            }else {
                ++count;
            }
        }
        System.out.println(count);
    }
}*/

    //JAVA11
    //编写一个方法，该方法的返回值是两个不大于100的正整数的最小公倍数
/*import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int m = console.nextInt();
        int n = console.nextInt();
        int result = getCM(m, n);
        System.out.println(result);
    }
    public static int getCM(int m, int n){
        //write your code here......
        int max = m>n?m:n;
        int min = m<n?m:n;
        for (int i = max; i <= max*min; i++) {
            if (i%m == 0 && i%n == 0) {
                return i;
            }
        }
        return -1;
    }
}*/

    //JAVA12
    //一球从h米高度自由落下，每次落地后反弹回原高度的一半再落下，求它在第n次落地时共经过了多少米？第n次反弹多高？
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        float h=scanner.nextFloat();
        int n =scanner.nextInt();
        float sum = h;
        for (int i = 0; i < n; i++){
            h /= 2;
            float num = h*2;
            sum += num;
        }
        sum = sum - h*2;
        System.out.println(String.format("%.3f", h)+" "+String.format("%.3f", sum));
    }
}*/

    //JAVA13
    //键盘输入任意多个10000以内正整数（负数代表结束），求出它们的平均数，
/*import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double avg = 0;
        int sum = 0;
        int count = 0;
        while (true) {
            int num = scan.nextInt();
            if (num < 0) break;
            sum += num;
            ++count;
        }
        avg = (double)sum/count;
        System.out.println(String.format("%.2f",avg));
    }
}*/


    //JAVA14
    //请补全预设代码中判断质数的方法。
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        Scanner scan = new Scanner(System.in);
        int number = scan.nextInt();
        System.out.println(main.isPrimeNumber(number));
    }

    public Boolean isPrimeNumber(int number) {

        //write your code here......
        for (int i = 2; i < number/2; i++) {
            if (number % i == 0) {
                return false;
            }
        }
        return true;
    }
}*/


    //JAVA15
    //输入一个整数，计算它的位数。如果输入的整数不大于0则输出这个数
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        scan.close();

        //write code here......
        int count = 0;
        if (num == 0) {
            System.out.println("0");
        }
        if (num == -1) {
            System.out.println("-1");
        }
        while (true) {
            ++count;
            num /= 10;
            if (num == 0) break;
        }
        System.out.println(count);
    }
}*/

//数组
    //JAVA16
    //将用户输入的六个数字填入数组并找出数组中最大值和最小值
/*import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] ary = new int[6];
        int max;
        int min;
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i <ary.length ; i++) {
            ary[i]=scanner.nextInt();
        }

        //write your code here......
        max = ary[0];
        min = ary[0];
        for (int i = 0; i < ary.length; i++) {
            if (max < ary[i]) {
                max = ary[i];
            }
            if (min > ary[i]) {
                min = ary[i];
            }
        }
        System.out.println(max+" "+min);
    }
}*/

    //JAVA17
    //输入6个整数，先将其输出然后再将数组倒转，再次输出数组
/*import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int[] arr = new int[6];
        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(Arrays.toString(arr));
        int left = 0;
        int right = arr.length-1;
        while (left <= right) {
            int tmp = arr[left];
            arr[left] = arr[right];
            arr[right] = tmp;
            ++left;
            --right;
        }
        System.out.println(Arrays.toString(arr));
    }
}*/

    
    //JAVA18
    //给定一个二维数组，请你编写一个求和函数，计算出这个数组元素的和
/*public class Main {
    public static void main(String[] args) {
        int[][]  arr = {{11, 33, 55}, {22, 44, 66, 88}, {131, 214, 315, 146}, {928, 827, 726, 625}, {424, 525}};
        int sum = add(arr);
        System.out.println(sum);
    }
    public static int add(int[][] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j <arr[i].length ; j++) {
                sum += arr[i][j];
            }
        }
        return sum;
    }
}*/
public class NiukeBasicGrammar1 {

}
